<?php
!defined('IN_SYSTEM') && exit('Access denied');
class sourceControlPage extends commonControlPage 
{
	/*[公司简介]*/
	public function companyModule()
	{
		if (POST && AJAX) 
		{
			$data = array();
			$data['type'] = 'company';
			$data['content'] = $_POST['content'];
			$data['createdate'] =  $_ENV['time'];;
			$id = UpdateTable('source', saddslashes($data),array('type'=>'company'));
			$this->outputJson(1,'操作成功');
		}
		$this->view->opt='company';
		$this->view->content=sourceEntity::GetCompanyContent();
		$this->showMainPage('admincp/source');
	}
	
	/*[公司简介]*/
	public function serviceModule()
	{
		if (POST && AJAX) 
		{
			$data = array();
			$data['type'] = 'service';
			$data['content'] = $_POST['content'];
			$data['createdate'] =  $_ENV['time'];;
			$id = UpdateTable('source', saddslashes($data),array('type'=>'service'));
			$this->outputJson(1,'操作成功');
		}
		$this->view->opt='service';
		$this->view->content=sourceEntity::GetServiceContent();
		$this->showMainPage('admincp/source');
	}
	
	
	
	/*[解决方案]*/
	public function caseModule()
	{
		if (POST && AJAX) 
		{
			$data = array();
			$data['type'] = 'case';
			$data['content'] = $_POST['content'];
			$data['createdate'] =  $_ENV['time'];;
			$id = UpdateTable('source', saddslashes($data),array('type'=>'case'));
			$this->outputJson(1,'操作成功');
		}
		$this->view->opt='case';
		$this->view->content=sourceEntity::GetCaseContent();
		$this->showMainPage('admincp/source');
	}
	/*[成功案例]*/
	public function successModule()
	{
		if (POST && AJAX) 
		{
			$data = array();
			$data['type'] = 'success';
			$data['content'] = $_POST['content'];
			$data['createdate'] =  $_ENV['time'];;
			$id = UpdateTable('source', saddslashes($data),array('type'=>'success'));
			$this->outputJson(1,'操作成功');
		}
		$this->view->opt='success';
		$this->view->content=sourceEntity::GetSuccessContent();
		$this->showMainPage('admincp/source');
	}
	
	/*[行业方案]*/
	public function hangyeModule()
	{
		if (POST && AJAX) 
		{
			$data = array();
			$data['type'] = 'hangye';
			$data['content'] = $_POST['content'];
			$data['createdate'] =  $_ENV['time'];;
			$id = UpdateTable('source', saddslashes($data),array('type'=>'hangye'));
			$this->outputJson(1,'操作成功');
		}
		$this->view->opt='hangye';
		$this->view->content=sourceEntity::GetHangyeContent();
		$this->showMainPage('admincp/source');
	}
	
	/*[行业范围方案]*/
	public function typeModule()
	{
		if (POST && AJAX) 
		{
			$bank = explode("\n",str_replace("\r",null,htmlspecialchars($_POST['content'])));
            foreach ($bank as $b) {
                if (mb_strlen($b,'UTF-8') > 15) {
                    $this->outputJson(0,"{$b}超过了15个字符的限制，无法提交");
                }
            }
			
			$data = array();
			$data['type'] = 'type';
			$data['content'] = $_POST['content'];
			$data['createdate'] =  $_ENV['time'];
			$id = UpdateTable('source', saddslashes($data),array('type'=>'type'));
			$this->outputJson(1,'操作成功');
		}
		$this->view->opt='type';
		$this->view->content=sourceEntity::GetTypeContent();
		$this->showMainPage('admincp/source');
	}
	
	/*[公告列表]*/
	public function gonggaoModule()
	{
        $this->view->gonggaos = sourceEntity::GetGongGaoList();
	    $this->view->opt='view';
		$this->view->view_act=' class="active" '; 
		$this->showMainPage('admincp/gonggao_manage');
	}
	
	/*[添加公告]*/
	public function addModule()
	{
		if (POST && AJAX) 
		{
			$data = array();
			$data['type'] = 'gonggao';
			$data['content'] = $_POST['content'];
			$data['createdate'] =  $_ENV['time'];
			$id = InsertTable('source', saddslashes($data));
			$this->outputJson(1,'操作成功');
		}
		$this->view->opt='add';
		$this->view->add_act=' class="active" '; 
		$this->showMainPage('admincp/gonggao_manage');
	}
	
	/*[编辑公告]*/
	public function editModule()
	{
		if (POST && AJAX) 
		{
			$data = array();
			$data['type'] = 'gonggao';
			$data['content'] = $_POST['content'];
			$data['createdate'] =  $_ENV['time'];
			$id = UpdateTable('source', saddslashes($data),array('sid'=>$_POST['sid']));
			$this->outputJson(1,'操作成功');
		}
		$sid = $_REQUEST['sid'];
		if(!$sid)
		{
			$this->outputJson(0,'非法操作');
		}
       	$this->view->gonggao = sourceEntity::GetRow($sid);
		$this->view->opt='edit';
		$this->view->edit_act=' class="active" '; 
		$this->showMainPage('admincp/gonggao_manage');
	}
	
	/*[删除公告]*/
    public function deleteModule()
	{
		if(AJAX) {
            $sid = $_GET['sid'];
 			$sum = sourceEntity::DeteteByID($sid);
            $this->outputJson(1,'操作成功');
        } else {
            $this->showMessage('Bad request');
        }
	}
}
?>